package com.ashlikun.camera.scan.util;

import android.app.Activity;
import android.content.Context;
import android.content.ContextWrapper;

import androidx.appcompat.view.ContextThemeWrapper;

import java.util.List;

/**
 * 作者　　: 李坤
 * 创建时间: 2024/2/23　15:15
 * 邮箱　　：496546144@qq.com
 * <p>
 * 功能介绍：
 */
public class CameraXUtils {
    public static Activity getActivity(Context context) {
        if (context == null) {
            return null;
        }
        if (context instanceof Activity) {
            return (Activity) context;
        } else if (context instanceof ContextWrapper) {
            return getActivity(((ContextWrapper) context).getBaseContext());
        } else if (context instanceof ContextThemeWrapper) {
            return getActivity(((ContextThemeWrapper) context).getBaseContext());
        }
        return null;
    }

    public static boolean isEmpty(List list) {
        return list == null || list.isEmpty();
    }

    public static boolean isEmpty(Object[] array) {
        return array == null || array.length == 0;
    }
}
